import { request } from "@/api/service";
import { BUTTON_STATUS_NUMBER } from "@/config/button";
import { urlPrefix as complaintsPrefix } from "./api";


export const crudOptions = vm => {
  return {
    pageOptions: {
      compact: true,
      export:{
        local:true,//本地导出，false为服务端导出
      }
    },
    options: {
      tableType: "vxe-table",
      rowKey: true, // 必须设置，true or false
      rowId: "id",
      height: "100%", // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Retrieve");
        }
      },
      edit: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Update");
        }
      },
      remove: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Delete");
        }
      }
    },
    indexRow: {
      // 或者直接传true,不显示title，不居中
      title: "序号",
      align: "center",
      width: 100
    },
    viewOptions: {
      componentType: "form"
    },
    formOptions: {
      defaultSpan: 24, // 默认的表单 span
      width: "35%"
    },
    columns: [{
      title: "ID",
      key: "id",
      show: false,
      disabled: true,
      width: 90,
      form: {
        disabled: true
      }
    }, {
      title: "企业名称",
      key: "企业名称",
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "企业名称必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入企业名称"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "统一社会信用代码",
      key: "统一社会信用代码",
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "统一社会信用代码必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入统一社会信用代码"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "经营场所",
      key: "经营场所",
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "经营场所必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入经营场所"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "辖区",
      key: "辖区",
      sortable: true,
      treeNode: true,



      search: {
        disabled: false,
        component: {
          props: {
            clearable: true
          }
        }
      },

      type: "select",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "辖区必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入辖区"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      },
      dict: {  //本地数据字典
        data: [
          { value: '思明区', label: '思明区' },
          { value: '湖里区', label: '湖里区' },
          { value: '集美区', label: '集美区' },
          { value: '翔安区', label: '翔安区' },
          { value: '海沧区', label: '海沧区' },
          { value: '同安区', label: '同安区' }
        ]
      }
    },
    {
      title: "行业",
      key: "行业",
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "行业必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入行业"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "公司电话",
      key: "公司电话",
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "公司电话必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入公司电话"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "联系人",
      key: "联系人",
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "联系人必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入联系人"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "信息来源",
      key: "信息来源",
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "信息来源必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入信息来源"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    ].concat(vm.commonEndColumns())
  };
};
